home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 10 / BBS In A Box Volume X (AMUG) (January 1994).bin / Files / Prog / U-Z / VideoToolBox.cpt / VideoToolboxSources / IsNan.c < prev    next >
MacBinary  |  1993-02-22  |  4.5 KB  |  [TEXT/KAHL]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
66% dexvert Compact Compressed (Unix) (archive/compact) ext Supported
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, inited, Mon Feb 22 23:40:38 1993, modified Mon Feb 22 23:40:38 1993, creator Think C, type ASCII, 4010 bytes "IsNan.c" , at 0x102a 346 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[KAHL]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 07 49 73 4e 61 6e 2e | 63 00 00 00 00 00 00 00 |..IsNan.|c.......|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 4b 41 48 | 4c 01 00 00 00 00 00 00 |.TEXTKAH|L.......|
|00000050| 00 00 00 00 00 0f aa 00 | 00 01 5a a7 af 5b 46 a7 |........|..Z..[F.|
|00000060| af 5b 46 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |.[F.....|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 7a 15 00 00 |........|....z...|
|00000080| 2f 2a 20 49 73 4e 61 6e | 2e 63 0d 46 61 73 74 2c |/* IsNan|.c.Fast,|
|00000090| 20 70 6f 72 74 61 62 6c | 65 20 72 6f 75 74 69 6e | portabl|e routin|
|000000a0| 65 73 20 74 6f 20 63 68 | 65 63 6b 20 66 6f 72 20 |es to ch|eck for |
|000000b0| 49 45 45 45 20 74 72 61 | 6e 73 66 69 6e 69 74 65 |IEEE tra|nsfinite|
|000000c0| 20 6e 75 6d 62 65 72 73 | 3a 20 49 4e 46 20 61 6e | numbers|: INF an|
|000000d0| 64 20 4e 41 4e 2e 20 59 | 6f 75 0d 73 68 6f 75 6c |d NAN. Y|ou.shoul|
|000000e0| 64 20 61 6c 73 6f 20 6c | 6f 6f 6b 20 61 74 20 74 |d also l|ook at t|
|000000f0| 68 65 20 6d 61 63 72 6f | 20 49 73 46 69 6e 69 74 |he macro| IsFinit|
|00000100| 65 28 29 20 69 6e 20 56 | 69 64 65 6f 54 6f 6f 6c |e() in V|ideoTool|
|00000110| 62 6f 78 2e 68 2e 0d 0d | 49 73 4e 61 6e 20 61 6e |box.h...|IsNan an|
|00000120| 64 20 49 73 49 6e 66 20 | 61 73 73 75 6d 65 20 74 |d IsInf |assume t|
|00000130| 68 61 74 20 65 76 65 72 | 79 20 4e 41 4e 27 73 20 |hat ever|y NAN's |
|00000140| 6d 6f 73 74 20 73 69 67 | 6e 69 66 69 63 61 6e 74 |most sig|nificant|
|00000150| 20 6d 61 6e 74 69 73 73 | 61 20 62 69 74 20 69 73 | mantiss|a bit is|
|00000160| 20 73 65 74 2c 0d 77 68 | 69 63 68 20 69 73 20 61 | set,.wh|ich is a|
|00000170| 70 70 61 72 65 6e 74 6c | 79 20 61 6e 20 69 6e 66 |pparentl|y an inf|
|00000180| 6f 72 6d 61 6c 20 63 6f | 6e 76 65 6e 74 69 6f 6e |ormal co|nvention|
|00000190| 20 73 75 70 70 6f 72 74 | 65 64 20 62 79 20 74 68 | support|ed by th|
|000001a0| 65 20 49 6e 74 65 6c 20 | 6d 61 74 68 20 63 68 69 |e Intel |math chi|
|000001b0| 70 20 61 6e 64 0d 70 65 | 72 68 61 70 73 20 74 68 |p and.pe|rhaps th|
|000001c0| 65 20 4d 6f 74 6f 72 6f | 6c 61 20 6d 61 74 68 20 |e Motoro|la math |
|000001d0| 63 68 69 70 2e 20 54 68 | 65 20 64 65 66 69 6e 69 |chip. Th|e defini|
|000001e0| 74 69 6f 6e 20 6f 66 20 | 61 20 4e 41 4e 20 69 6e |tion of |a NAN in|
|000001f0| 20 74 68 65 20 41 70 70 | 6c 65 20 4e 75 6d 65 72 | the App|le Numer|
|00000200| 69 63 73 0d 62 6f 6f 6b | 20 6f 6e 6c 79 20 73 61 |ics.book| only sa|
|00000210| 79 73 20 74 68 61 74 20 | 61 20 4e 41 4e 20 69 73 |ys that |a NAN is|
|00000220| 20 64 69 73 74 69 6e 67 | 75 69 73 68 65 64 20 66 | disting|uished f|
|00000230| 72 6f 6d 20 61 6e 20 49 | 4e 46 20 62 79 20 68 61 |rom an I|NF by ha|
|00000240| 76 69 6e 67 20 61 20 6e | 6f 6e 7a 65 72 6f 0d 6d |ving a n|onzero.m|
|00000250| 61 6e 74 69 73 73 61 2e | 20 55 6e 66 6f 72 74 75 |antissa.| Unfortu|
|00000260| 6e 61 74 65 6c 79 2c 20 | 61 20 73 74 72 69 63 74 |nately, |a strict|
|00000270| 20 74 65 73 74 20 6f 66 | 20 74 68 69 73 20 77 6f | test of| this wo|
|00000280| 75 6c 64 20 72 65 71 75 | 69 72 65 20 74 65 73 74 |uld requ|ire test|
|00000290| 69 6e 67 20 61 6c 6c 20 | 38 0d 62 79 74 65 73 2c |ing all |8.bytes,|
|000002a0| 20 61 6e 64 20 69 6e 20 | 66 61 63 74 20 74 68 65 | and in |fact the|
|000002b0| 20 72 6f 75 74 69 6e 65 | 73 20 69 6e 20 50 6c 61 | routine|s in Pla|
|000002c0| 75 67 68 65 72 27 73 20 | 54 68 65 20 53 74 61 6e |ugher's |The Stan|
|000002d0| 64 61 72 64 20 43 20 4c | 69 62 72 61 72 79 20 64 |dard C L|ibrary d|
|000002e0| 6f 20 65 78 61 63 74 6c | 79 0d 74 68 69 73 2e 20 |o exactl|y.this. |
|000002f0| 48 6f 77 65 76 65 72 2c | 20 74 68 69 73 20 73 65 |However,| this se|
|00000300| 65 6d 73 20 77 61 73 74 | 65 66 75 6c 20 73 69 6e |ems wast|eful sin|
|00000310| 63 65 20 74 68 65 20 32 | 35 35 20 64 69 66 66 65 |ce the 2|55 diffe|
|00000320| 72 65 6e 74 20 4e 41 4e | 73 20 74 68 61 74 20 63 |rent NAN|s that c|
|00000330| 61 6e 20 62 65 0d 73 70 | 65 63 69 66 69 65 64 20 |an be.sp|ecified |
|00000340| 62 79 20 74 68 65 20 6f | 6e 65 20 62 79 74 65 20 |by the o|ne byte |
|00000350| 4e 41 4e 20 74 79 70 65 | 20 61 72 65 20 6f 62 76 |NAN type| are obv|
|00000360| 69 6f 75 73 6c 79 20 6d | 6f 72 65 20 74 68 61 6e |iously m|ore than|
|00000370| 20 65 6e 6f 75 67 68 20 | 66 6f 72 20 6d 6f 73 74 | enough |for most|
|00000380| 0d 70 72 6f 67 72 61 6d | 73 2e 20 49 6e 64 65 65 |.program|s. Indee|
|00000390| 64 2c 20 73 69 6e 63 65 | 20 74 68 65 20 4d 6f 74 |d, since| the Mot|
|000003a0| 6f 72 6f 6c 61 20 63 68 | 69 70 20 64 6f 65 73 6e |orola ch|ip doesn|
|000003b0| 27 74 20 70 72 65 73 65 | 72 76 65 20 4e 41 4e 20 |'t prese|rve NAN |
|000003c0| 74 79 70 65 2c 20 74 68 | 65 20 6e 75 6d 62 65 72 |type, th|e number|
|000003d0| 0d 6f 66 20 4e 41 4e 20 | 74 79 70 65 73 20 69 73 |.of NAN |types is|
|000003e0| 20 72 61 74 68 65 72 20 | 61 63 61 64 65 6d 69 63 | rather |academic|
|000003f0| 3b 20 61 20 73 69 6e 67 | 6c 65 20 4e 41 4e 20 74 |; a sing|le NAN t|
|00000400| 79 70 65 20 73 65 65 6d | 73 20 74 6f 20 62 65 20 |ype seem|s to be |
|00000410| 70 6c 65 6e 74 79 20 66 | 6f 72 20 6d 6f 73 74 0d |plenty f|or most.|
|00000420| 61 70 70 6c 69 63 61 74 | 69 6f 6e 73 2e 20 57 68 |applicat|ions. Wh|
|00000430| 69 6c 65 20 69 74 20 69 | 73 20 70 6f 73 73 69 62 |ile it i|s possib|
|00000440| 6c 65 20 74 6f 20 61 73 | 73 65 6d 62 6c 65 20 61 |le to as|semble a|
|00000450| 20 4e 41 4e 20 77 69 74 | 68 20 7a 65 72 6f 20 74 | NAN wit|h zero t|
|00000460| 79 70 65 2c 20 77 68 69 | 63 68 20 69 73 0d 70 72 |ype, whi|ch is.pr|
|00000470| 65 73 65 72 76 65 64 20 | 74 68 72 6f 75 67 68 20 |eserved |through |
|00000480| 38 38 38 31 20 6f 70 65 | 72 61 74 69 6f 6e 73 2c |8881 ope|rations,|
|00000490| 20 61 6e 64 20 77 68 69 | 63 68 20 70 72 69 6e 74 | and whi|ch print|
|000004a0| 66 28 22 25 66 22 29 20 | 70 72 69 6e 74 73 20 61 |f("%f") |prints a|
|000004b0| 73 20 4e 41 4e 30 30 2c | 20 74 68 65 0d 53 41 4e |s NAN00,| the.SAN|
|000004c0| 45 20 72 6f 75 74 69 6e | 65 73 20 61 6c 6c 20 73 |E routin|es all s|
|000004d0| 65 65 6d 20 74 6f 20 69 | 6d 6d 65 64 69 61 74 65 |eem to i|mmediate|
|000004e0| 6c 79 20 63 6f 6e 76 65 | 72 74 20 74 68 65 20 7a |ly conve|rt the z|
|000004f0| 65 72 6f 20 74 79 70 65 | 20 4e 41 4e 20 74 6f 20 |ero type| NAN to |
|00000500| 74 79 70 65 20 34 2c 20 | 73 6f 20 49 73 4e 61 6e |type 4, |so IsNan|
|00000510| 28 29 0d 64 6f 65 73 20 | 74 6f 6f 2e 0d 0d 54 68 |().does |too...Th|
|00000520| 65 20 61 73 73 65 72 74 | 28 29 20 74 65 73 74 73 |e assert|() tests|
|00000530| 20 72 65 66 65 72 72 69 | 6e 67 20 74 6f 20 73 69 | referri|ng to si|
|00000540| 7a 65 6f 66 28 64 6f 75 | 62 6c 65 29 20 61 72 65 |zeof(dou|ble) are|
|00000550| 20 65 76 61 6c 75 61 74 | 65 64 20 62 79 20 74 68 | evaluat|ed by th|
|00000560| 65 20 63 6f 6d 70 69 6c | 65 72 2c 20 77 69 74 68 |e compil|er, with|
|00000570| 20 6e 6f 20 0d 72 75 6e | 74 69 6d 65 20 70 65 6e | no .run|time pen|
|00000580| 61 6c 74 79 2e 0d 0d 48 | 49 53 54 4f 52 59 3a 0d |alty...H|ISTORY:.|
|00000590| 38 2f 32 34 2f 39 31 20 | 64 67 70 09 6d 61 64 65 |8/24/91 |dgp.made|
|000005a0| 20 63 6f 6d 70 61 74 69 | 62 6c 65 20 77 69 74 68 | compati|ble with|
|000005b0| 20 54 48 49 4e 4b 20 43 | 20 35 2e 30 2e 0d 31 32 | THINK C| 5.0..12|
|000005c0| 2f 32 33 2f 39 31 20 64 | 67 70 20 49 20 72 65 70 |/23/91 d|gp I rep|
|000005d0| 6c 61 63 65 64 20 74 68 | 65 20 23 69 66 20 73 74 |laced th|e #if st|
|000005e0| 61 74 65 6d 65 6e 74 73 | 20 62 79 20 6f 72 64 69 |atements| by ordi|
|000005f0| 6e 61 72 79 20 69 66 20 | 73 74 61 74 65 6d 65 6e |nary if |statemen|
|00000600| 74 73 2c 20 77 68 69 63 | 68 20 61 72 65 20 0d 09 |ts, whic|h are ..|
|00000610| 6d 6f 72 65 20 72 65 61 | 64 61 62 6c 65 20 61 6e |more rea|dable an|
|00000620| 64 20 61 72 65 20 61 6c | 6c 6f 77 65 64 20 74 6f |d are al|lowed to|
|00000630| 20 75 73 65 20 74 68 65 | 20 73 69 7a 65 6f 66 28 | use the| sizeof(|
|00000640| 29 20 6f 70 65 72 61 74 | 6f 72 2e 0d 09 4e 6f 74 |) operat|or...Not|
|00000650| 65 20 74 68 61 74 20 6d | 6f 73 74 20 6f 66 20 74 |e that m|ost of t|
|00000660| 68 65 20 69 66 20 73 74 | 61 74 65 6d 65 6e 74 73 |he if st|atements|
|00000670| 20 77 69 6c 6c 20 62 65 | 20 65 76 61 6c 75 61 74 | will be| evaluat|
|00000680| 65 64 20 61 6e 64 20 72 | 65 6d 6f 76 65 64 20 62 |ed and r|emoved b|
|00000690| 79 20 74 68 65 0d 09 63 | 6f 6d 70 69 6c 65 72 2c |y the..c|ompiler,|
|000006a0| 20 77 69 74 68 20 6e 6f | 20 72 75 6e 74 69 6d 65 | with no| runtime|
|000006b0| 20 70 65 6e 61 6c 74 79 | 2e 0d 31 32 2f 32 33 2f | penalty|..12/23/|
|000006c0| 39 31 20 64 67 70 20 57 | 72 6f 74 65 20 6d 79 20 |91 dgp W|rote my |
|000006d0| 6f 77 6e 20 63 6f 64 65 | 20 74 6f 20 72 65 70 6c |own code| to repl|
|000006e0| 61 63 65 20 74 68 65 20 | 53 41 4e 45 20 63 6f 64 |ace the |SANE cod|
|000006f0| 65 20 73 69 6e 63 65 20 | 69 74 27 73 20 74 6f 6f |e since |it's too|
|00000700| 20 73 6c 6f 77 2e 0d 09 | 54 68 69 73 20 6d 61 6b | slow...|This mak|
|00000710| 65 73 20 49 73 4e 61 6e | 28 29 20 61 62 6f 75 74 |es IsNan|() about|
|00000720| 20 35 20 74 69 6d 65 73 | 20 66 61 73 74 65 72 2e | 5 times| faster.|
|00000730| 0d 09 4d 79 20 63 6f 64 | 65 20 69 73 20 62 61 73 |..My cod|e is bas|
|00000740| 65 64 20 6f 6e 20 74 68 | 65 20 41 70 70 6c 65 20 |ed on th|e Apple |
|00000750| 4e 75 6d 65 72 69 63 73 | 20 4d 61 6e 75 61 6c 2c |Numerics| Manual,|
|00000760| 20 32 6e 64 20 65 64 69 | 74 69 6f 6e 2e 20 49 74 | 2nd edi|tion. It|
|00000770| 20 73 61 79 73 20 74 68 | 61 74 0d 09 61 20 6e 75 | says th|at..a nu|
|00000780| 6d 62 65 72 20 69 73 20 | 61 20 4e 41 4e 20 69 66 |mber is |a NAN if|
|00000790| 66 20 74 68 65 20 65 78 | 70 6f 6e 65 6e 74 20 69 |f the ex|ponent i|
|000007a0| 73 20 61 6c 6c 20 6f 6e | 65 73 20 61 6e 64 20 74 |s all on|es and t|
|000007b0| 68 65 20 66 72 61 63 74 | 69 6f 6e 20 69 73 20 6e |he fract|ion is n|
|000007c0| 6f 6e 7a 65 72 6f 2e 0d | 09 49 20 6d 61 6b 65 20 |onzero..|.I make |
|000007d0| 61 20 73 6c 69 67 68 74 | 20 73 68 6f 72 74 63 75 |a slight| shortcu|
|000007e0| 74 20 69 6e 20 63 68 65 | 63 6b 69 6e 67 20 6f 6e |t in che|cking on|
|000007f0| 6c 79 20 74 68 65 20 74 | 6f 70 20 31 35 20 62 69 |ly the t|op 15 bi|
|00000800| 74 73 20 6f 66 20 74 68 | 65 20 66 72 61 63 74 69 |ts of th|e fracti|
|00000810| 6f 6e 2c 0d 09 73 69 6e | 63 65 20 74 68 61 74 20 |on,..sin|ce that |
|00000820| 69 6e 63 6c 75 64 65 73 | 20 74 68 65 20 62 79 74 |includes| the byt|
|00000830| 65 20 74 68 61 74 20 73 | 70 65 63 69 66 69 65 73 |e that s|pecifies|
|00000840| 20 74 68 65 20 4e 41 4e | 20 74 79 70 65 2c 20 6f | the NAN| type, o|
|00000850| 6e 20 74 68 65 20 70 72 | 65 6d 69 73 65 0d 09 74 |n the pr|emise..t|
|00000860| 68 61 74 20 61 6c 6c 20 | 4e 41 4e 73 20 74 68 61 |hat all |NANs tha|
|00000870| 74 20 49 20 77 69 6c 6c | 20 61 63 74 75 61 6c 6c |t I will| actuall|
|00000880| 79 20 73 65 65 20 69 6e | 20 70 72 61 63 74 69 63 |y see in| practic|
|00000890| 65 20 77 69 6c 6c 20 68 | 61 76 65 20 6e 6f 6e 7a |e will h|ave nonz|
|000008a0| 65 72 6f 20 74 79 70 65 | 2e 0d 09 4d 79 20 63 6f |ero type|...My co|
|000008b0| 64 65 20 68 61 6e 64 6c | 65 73 20 74 68 65 20 6f |de handl|es the o|
|000008c0| 72 64 69 6e 61 72 79 20 | 63 61 73 65 73 20 6f 66 |rdinary |cases of|
|000008d0| 20 31 30 20 6f 72 20 31 | 32 20 62 79 74 65 20 64 | 10 or 1|2 byte d|
|000008e0| 6f 75 62 6c 65 73 2e 20 | 54 68 65 20 77 65 69 72 |oubles. |The weir|
|000008f0| 64 0d 09 63 61 73 65 20 | 6f 66 20 73 68 6f 72 74 |d..case |of short|
|00000900| 65 72 20 64 6f 75 62 6c | 65 73 20 28 77 68 69 63 |er doubl|es (whic|
|00000910| 68 20 61 72 65 20 75 6e | 6c 69 6b 65 6c 79 20 73 |h are un|likely s|
|00000920| 69 6e 63 65 20 74 68 65 | 79 20 72 75 6e 20 76 65 |ince the|y run ve|
|00000930| 72 79 20 73 6c 6f 77 6c | 79 29 0d 09 61 72 65 20 |ry slowl|y)..are |
|00000940| 64 65 74 65 63 74 65 64 | 20 62 79 20 74 68 65 20 |detected| by the |
|00000950| 61 73 73 65 72 74 28 29 | 20 74 65 73 74 20 61 74 |assert()| test at|
|00000960| 20 74 68 65 20 62 65 67 | 69 6e 6e 69 6e 67 2e 0d | the beg|inning..|
|00000970| 31 32 2f 32 33 2f 39 31 | 20 64 67 70 20 41 73 6b |12/23/91| dgp Ask|
|00000980| 65 64 20 74 68 65 20 54 | 48 49 4e 4b 20 43 20 63 |ed the T|HINK C c|
|00000990| 6f 6d 70 69 6c 65 72 20 | 6e 6f 74 20 74 6f 20 74 |ompiler |not to t|
|000009a0| 69 6d 65 20 74 68 69 73 | 20 72 6f 75 74 69 6e 65 |ime this| routine|
|000009b0| 2e 0d 31 32 2f 32 39 2f | 39 31 20 64 67 70 20 45 |..12/29/|91 dgp E|
|000009c0| 6c 69 6d 69 6e 61 74 65 | 64 20 74 68 65 20 6e 65 |liminate|d the ne|
|000009d0| 65 64 20 66 6f 72 20 53 | 61 6e 65 2e 68 20 61 6e |ed for S|ane.h an|
|000009e0| 64 20 54 79 70 65 73 2e | 68 2e 20 54 68 65 20 73 |d Types.|h. The s|
|000009f0| 61 6e 65 20 73 74 75 66 | 66 0d 09 6e 6f 77 20 61 |ane stuf|f..now a|
|00000a00| 70 70 65 61 72 73 20 69 | 6e 20 69 74 73 20 6f 77 |ppears i|n its ow|
|00000a10| 6e 20 66 69 6c 65 3a 20 | 53 61 6e 65 2e 63 2e 20 |n file: |Sane.c. |
|00000a20| 0d 09 57 72 6f 74 65 20 | 49 73 49 6e 66 28 29 2e |..Wrote |IsInf().|
|00000a30| 0d 09 57 72 6f 74 65 20 | 61 20 6e 65 77 20 6d 61 |..Wrote |a new ma|
|00000a40| 63 72 6f 20 64 65 66 69 | 6e 69 74 69 6f 6e 2c 20 |cro defi|nition, |
|00000a50| 69 6e 20 56 69 64 65 6f | 54 6f 6f 6c 62 6f 78 2e |in Video|Toolbox.|
|00000a60| 68 2c 20 66 6f 72 20 49 | 73 46 69 6e 69 74 65 28 |h, for I|sFinite(|
|00000a70| 29 2c 20 0d 09 74 68 61 | 74 20 61 6c 6c 6f 77 73 |), ..tha|t allows|
|00000a80| 20 66 61 73 74 20 69 6e | 6c 69 6e 65 20 74 65 73 | fast in|line tes|
|00000a90| 74 69 6e 67 20 66 6f 72 | 20 77 68 65 74 68 65 72 |ting for| whether|
|00000aa0| 20 61 20 6e 75 6d 62 65 | 72 20 69 73 20 6f 6b 2c | a numbe|r is ok,|
|00000ab0| 20 69 2e 65 2e 20 6e 65 | 69 74 68 65 72 20 0d 09 | i.e. ne|ither ..|
|00000ac0| 4e 41 4e 20 6e 6f 72 20 | 49 4e 46 2e 20 0d 31 2f |NAN nor |INF. .1/|
|00000ad0| 31 34 2f 39 32 09 64 67 | 70 09 43 68 61 6e 67 65 |14/92.dg|p.Change|
|00000ae0| 64 20 49 73 4e 61 6e 28 | 29 20 74 6f 20 6e 6f 77 |d IsNan(|) to now|
|00000af0| 20 72 65 74 75 72 6e 20 | 74 68 65 20 74 79 70 65 | return |the type|
|00000b00| 20 28 31 2e 2e 32 35 35 | 29 20 6f 66 20 74 68 65 | (1..255|) of the|
|00000b10| 20 4e 41 4e 2c 20 6f 72 | 20 7a 65 72 6f 0d 09 69 | NAN, or| zero..i|
|00000b20| 66 20 6e 6f 74 20 61 20 | 4e 41 4e 2e 20 54 68 69 |f not a |NAN. Thi|
|00000b30| 73 20 77 69 6c 6c 20 62 | 72 65 61 6b 20 70 72 6f |s will b|reak pro|
|00000b40| 67 72 61 6d 73 20 74 68 | 61 74 20 61 73 73 75 6d |grams th|at assum|
|00000b50| 65 20 74 68 65 20 74 72 | 75 65 20 76 61 6c 75 65 |e the tr|ue value|
|00000b60| 20 69 73 20 61 6c 77 61 | 79 73 20 31 2c 0d 09 65 | is alwa|ys 1,..e|
|00000b70| 2e 67 2e 20 6e 61 6e 73 | 2b 3d 49 73 4e 61 6e 28 |.g. nans|+=IsNan(|
|00000b80| 61 29 3b 0d 09 46 69 78 | 65 64 20 49 73 49 6e 66 |a);..Fix|ed IsInf|
|00000b90| 28 29 20 74 6f 20 63 6f | 72 72 65 63 74 6c 79 20 |() to co|rrectly |
|00000ba0| 72 65 74 75 72 6e 20 73 | 69 67 6e 20 6f 66 20 b1 |return s|ign of .|
|00000bb0| 49 4e 46 2e 0d 31 2f 31 | 38 2f 39 32 09 64 67 70 |INF..1/1|8/92.dgp|
|00000bc0| 09 52 65 77 72 6f 74 65 | 20 72 6f 75 74 69 6e 65 |.Rewrote| routine|
|00000bd0| 73 2c 20 6d 61 6b 69 6e | 67 20 74 68 65 6d 20 73 |s, makin|g them s|
|00000be0| 69 6d 70 6c 65 72 2c 20 | 61 6e 64 20 61 6c 77 61 |impler, |and alwa|
|00000bf0| 79 73 20 63 68 65 63 6b | 69 6e 67 20 74 68 65 20 |ys check|ing the |
|00000c00| 6d 6f 73 74 20 0d 09 73 | 69 67 6e 69 66 69 63 61 |most ..s|ignifica|
|00000c10| 6e 74 20 62 69 74 20 6f | 66 20 74 68 65 20 6d 61 |nt bit o|f the ma|
|00000c20| 6e 74 69 73 73 61 20 69 | 6e 20 74 65 73 74 69 6e |ntissa i|n testin|
|00000c30| 67 20 66 6f 72 20 4e 41 | 4e 2e 0d 2a 2f 0d 0d 23 |g for NA|N..*/..#|
|00000c40| 69 6e 63 6c 75 64 65 20 | 22 56 69 64 65 6f 54 6f |include |"VideoTo|
|00000c50| 6f 6c 62 6f 78 2e 68 22 | 0d 23 69 6e 63 6c 75 64 |olbox.h"|.#includ|
|00000c60| 65 20 3c 61 73 73 65 72 | 74 2e 68 3e 0d 23 69 66 |e <asser|t.h>.#if|
|00000c70| 20 54 48 49 4e 4b 5f 43 | 0d 09 23 70 72 61 67 6d | THINK_C|..#pragm|
|00000c80| 61 20 6f 70 74 69 6f 6e | 73 28 21 70 72 6f 66 69 |a option|s(!profi|
|00000c90| 6c 65 29 09 2f 2a 20 41 | 74 74 72 69 62 75 74 65 |le)./* A|ttribute|
|00000ca0| 20 74 6f 20 74 68 65 20 | 63 61 6c 6c 65 72 20 74 | to the |caller t|
|00000cb0| 68 65 20 74 69 6d 65 20 | 73 70 65 6e 74 20 68 65 |he time |spent he|
|00000cc0| 72 65 2e 20 2a 2f 0d 23 | 65 6e 64 69 66 0d 23 64 |re. */.#|endif.#d|
|00000cd0| 65 66 69 6e 65 20 45 58 | 50 4f 4e 45 4e 54 20 30 |efine EX|PONENT 0|
|00000ce0| 0d 23 64 65 66 69 6e 65 | 20 4d 41 4e 54 49 53 53 |.#define| MANTISS|
|00000cf0| 41 20 28 31 2b 28 73 69 | 7a 65 6f 66 28 64 6f 75 |A (1+(si|zeof(dou|
|00000d00| 62 6c 65 29 2d 31 30 29 | 2f 73 69 7a 65 6f 66 28 |ble)-10)|/sizeof(|
|00000d10| 73 68 6f 72 74 29 29 0d | 0d 69 6e 74 20 49 73 4e |short)).|.int IsN|
|00000d20| 61 6e 28 64 6f 75 62 6c | 65 20 78 29 0d 2f 2a 20 |an(doubl|e x)./* |
|00000d30| 52 65 74 75 72 6e 73 20 | 78 27 73 20 4e 41 4e 20 |Returns |x's NAN |
|00000d40| 74 79 70 65 20 28 31 2e | 2e 2e 32 35 35 29 20 6f |type (1.|..255) o|
|00000d50| 72 20 7a 65 72 6f 20 69 | 66 20 78 20 69 73 20 6e |r zero i|f x is n|
|00000d60| 6f 74 20 61 20 4e 41 4e | 2e 20 2a 2f 0d 2f 2a 20 |ot a NAN|. */./* |
|00000d70| 49 66 20 4e 61 4e 20 74 | 79 70 65 20 69 73 20 7a |If NaN t|ype is z|
|00000d80| 65 72 6f 2c 20 72 65 74 | 75 72 6e 20 34 2c 20 61 |ero, ret|urn 4, a|
|00000d90| 73 20 64 6f 20 74 68 65 | 20 41 70 70 6c 65 20 72 |s do the| Apple r|
|00000da0| 6f 75 74 69 6e 65 73 2e | 20 2a 2f 0d 7b 0d 09 72 |outines.| */.{..r|
|00000db0| 65 67 69 73 74 65 72 20 | 73 68 6f 72 74 20 69 3b |egister |short i;|
|00000dc0| 0d 0d 09 61 73 73 65 72 | 74 28 73 69 7a 65 6f 66 |...asser|t(sizeof|
|00000dd0| 28 64 6f 75 62 6c 65 29 | 3d 3d 31 30 20 7c 7c 20 |(double)|==10 || |
|00000de0| 73 69 7a 65 6f 66 28 64 | 6f 75 62 6c 65 29 3d 3d |sizeof(d|ouble)==|
|00000df0| 31 32 29 3b 0d 09 69 66 | 28 28 28 28 73 68 6f 72 |12);..if|((((shor|
|00000e00| 74 20 2a 29 26 78 29 5b | 45 58 50 4f 4e 45 4e 54 |t *)&x)[|EXPONENT|
|00000e10| 5d 20 26 20 30 78 37 46 | 46 46 29 3d 3d 30 78 37 |] & 0x7F|FF)==0x7|
|00000e20| 46 46 46 29 7b 09 09 2f | 2f 20 65 69 74 68 65 72 |FFF){../|/ either|
|00000e30| 20 4e 41 4e 20 6f 72 20 | 49 4e 46 0d 09 09 69 3d | NAN or |INF...i=|
|00000e40| 28 28 73 68 6f 72 74 20 | 2a 29 26 78 29 5b 4d 41 |((short |*)&x)[MA|
|00000e50| 4e 54 49 53 53 41 5d 20 | 26 20 30 78 37 46 46 46 |NTISSA] |& 0x7FFF|
|00000e60| 3b 0d 09 09 69 66 28 69 | 3d 3d 30 29 72 65 74 75 |;...if(i|==0)retu|
|00000e70| 72 6e 20 30 3b 0d 09 09 | 69 26 3d 30 78 46 46 3b |rn 0;...|i&=0xFF;|
|00000e80| 0d 09 09 69 66 28 69 21 | 3d 30 29 72 65 74 75 72 |...if(i!|=0)retur|
|00000e90| 6e 20 69 3b 0d 09 09 65 | 6c 73 65 20 72 65 74 75 |n i;...e|lse retu|
|00000ea0| 72 6e 20 34 3b 0d 09 7d | 20 65 6c 73 65 20 72 65 |rn 4;..}| else re|
|00000eb0| 74 75 72 6e 20 30 3b 0d | 7d 0d 0d 69 6e 74 20 49 |turn 0;.|}..int I|
|00000ec0| 73 49 6e 66 28 64 6f 75 | 62 6c 65 20 78 29 0d 2f |sInf(dou|ble x)./|
|00000ed0| 2a 20 52 65 74 75 72 6e | 73 20 2d 31 20 66 6f 72 |* Return|s -1 for|
|00000ee0| 20 2d 49 4e 46 2c 20 30 | 20 66 6f 72 20 6e 6f 74 | -INF, 0| for not|
|00000ef0| 20 49 4e 46 2c 20 61 6e | 64 20 2b 31 20 66 6f 72 | INF, an|d +1 for|
|00000f00| 20 2b 49 4e 46 2e 20 2a | 2f 0d 7b 0d 09 72 65 67 | +INF. *|/.{..reg|
|00000f10| 69 73 74 65 72 20 73 68 | 6f 72 74 20 69 3b 0d 0d |ister sh|ort i;..|
|00000f20| 09 61 73 73 65 72 74 28 | 73 69 7a 65 6f 66 28 64 |.assert(|sizeof(d|
|00000f30| 6f 75 62 6c 65 29 3d 3d | 31 30 20 7c 7c 20 73 69 |ouble)==|10 || si|
|00000f40| 7a 65 6f 66 28 64 6f 75 | 62 6c 65 29 3d 3d 31 32 |zeof(dou|ble)==12|
|00000f50| 29 3b 0d 09 69 3d 28 28 | 73 68 6f 72 74 20 2a 29 |);..i=((|short *)|
|00000f60| 26 78 29 5b 45 58 50 4f | 4e 45 4e 54 5d 3b 0d 09 |&x)[EXPO|NENT];..|
|00000f70| 69 66 28 28 69 20 26 20 | 30 78 37 46 46 46 29 3d |if((i & |0x7FFF)=|
|00000f80| 3d 30 78 37 46 46 46 29 | 7b 09 09 09 09 09 09 09 |=0x7FFF)|{.......|
|00000f90| 2f 2f 20 65 69 74 68 65 | 72 20 4e 41 4e 20 6f 72 |// eithe|r NAN or|
|00000fa0| 20 49 4e 46 0d 09 09 69 | 66 28 28 28 28 73 68 6f | INF...i|f((((sho|
|00000fb0| 72 74 20 2a 29 26 78 29 | 5b 4d 41 4e 54 49 53 53 |rt *)&x)|[MANTISS|
|00000fc0| 41 5d 20 26 20 30 78 37 | 46 46 46 29 3d 3d 30 29 |A] & 0x7|FFF)==0)|
|00000fd0| 7b 0d 09 09 09 69 66 28 | 69 3c 30 29 72 65 74 75 |{....if(|i<0)retu|
|00000fe0| 72 6e 20 2d 31 3b 09 09 | 09 09 09 09 09 2f 2f 20 |rn -1;..|.....// |
|00000ff0| 2d 49 4e 46 0d 09 09 09 | 65 6c 73 65 20 72 65 74 |-INF....|else ret|
|00001000| 75 72 6e 20 31 3b 09 09 | 09 09 09 09 09 09 2f 2f |urn 1;..|......//|
|00001010| 20 2b 49 4e 46 0d 09 09 | 7d 0d 09 7d 0d 09 72 65 | +INF...|}..}..re|
|00001020| 74 75 72 6e 20 30 3b 0d | 7d 0d 00 00 00 00 00 00 |turn 0;.|}.......|
|00001030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001040| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001050| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001060| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001070| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001080| 00 00 01 00 00 00 01 28 | 00 00 00 28 00 00 00 32 |.......(|...(...2|
|00001090| 8d 01 67 3e 7f 02 20 ad | fb fe 7f 7e 01 00 74 4c |..g>.. .|...~..tL|
|000010a0| 01 f9 78 7f 7e 01 00 70 | 4c 01 f9 6e 8d 6d 20 05 |..x.~..p|L..n.m .|
|000010b0| 07 49 73 4e 61 6e 2e 63 | 02 00 00 00 54 45 58 54 |.IsNan.c|....TEXT|
|000010c0| 4b 41 48 4c 00 00 00 00 | 00 00 00 00 00 00 31 ff |KAHL....|......1.|
|000010d0| 00 00 54 45 58 54 4b 41 | 48 4c 00 00 00 00 00 00 |..TEXTKA|HL......|
|000010e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000010f0| 00 00 a7 e5 d5 bb 00 00 | 00 00 00 00 01 5a 13 ed |........|.....Z..|
|00001100| 08 02 00 00 40 03 81 2b | 00 15 4a 81 67 01 67 70 |....@..+|..J.g.gp|
|00001110| 60 50 01 15 aa f4 b2 5f | 95 95 3c 01 08 82 7c ba |`P....._|..<...|.|
|00001120| 78 56 7f 13 48 68 00 68 | 4e ad 01 08 6a 67 de b4 |xV..Hh.h|N...jg..|
|00001130| 15 d2 80 2f 01 4e ad 04 | 92 3d 40 93 7c 5f 78 56 |.../.N..|.=@.|_xV|
|00001140| 7f 20 0b 01 08 72 67 de | b4 20 0c 5b 20 03 5f 02 |. ...rg.|. .[ ._.|
|00001150| 20 d9 20 d9 68 54 3e 3f | 4b 01 4a 6e 75 01 57 c0 | . .hT>?|K.Jnu.W.|
|00001160| fb 25 26 5a 4f 44 01 00 | a0 7f 01 08 e8 a3 3b 24 |.%&ZOD..|......;$|
|00001170| 01 ff c4 5c 9b 8c 4d 57 | 01 ff c8 50 13 02 02 4a |...\..MW|...P...J|
|00001180| 00 00 00 24 00 01 00 00 | 0f aa 00 00 0f aa 19 09 |...$....|........|
|00001190| 23 69 66 20 73 69 7a 65 | 6f 66 28 64 6f 75 62 6c |#if size|of(doubl|
|000011a0| 65 29 20 3d 3d 20 31 32 | 00 00 01 00 00 00 01 28 |e) == 12|.......(|
|000011b0| 00 00 00 28 00 00 00 32 | 00 f3 bf dc 26 90 00 00 |...(...2|....&...|
|000011c0| 00 1c 00 32 00 00 4d 50 | 53 52 00 00 00 0a 03 ef |...2..MP|SR......|
|000011d0| ff ff 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000011e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000011f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+